import { createApp } from 'vue'
import { createPinia } from 'pinia'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
import {
  Button,
  Field,
  Form,
  CellGroup,
  NavBar,
  Tabbar,
  TabbarItem,
  Icon,
  Toast,
  Grid,
  GridItem,
  Swipe,
  SwipeItem,
  Cell,
  Image as VanImage,
  Dialog,
  Empty,
  Popup,
  Picker,
  SwipeCell,
  Tag,
  Loading,
  PullRefresh,
  Search,
  List,
  ActionSheet,
  Radio,
  RadioGroup
} from 'vant'
import 'vant/lib/index.css'
import App from './App.vue'
import router from './router'
import 'amfe-flexible'
import './styles/index.scss'  // 导入全局样式

import './style.css'
import './assets/reset.css'

// 引入 echarts 核心模块
import * as echarts from 'echarts/core'
// 引入图表类型
import { LineChart } from 'echarts/charts'
// 引入需要的组件
import {
  TitleComponent,
  TooltipComponent,
  GridComponent,
  LegendComponent,
  DataZoomComponent,
  MarkPointComponent
} from 'echarts/components'
// 引入渲染器
import { CanvasRenderer } from 'echarts/renderers'

const app = createApp(App)
const pinia = createPinia()
pinia.use(piniaPluginPersistedstate)

// 注册 Vant 组件
const vantComponents = [
  Button,
  Field,
  Form,
  CellGroup,
  NavBar,
  Tabbar,
  TabbarItem,
  Icon,
  Toast,
  Grid,
  GridItem,
  Swipe,
  SwipeItem,
  Cell,
  VanImage,
  Dialog,
  Empty,
  Popup,
  Picker,
  SwipeCell,
  Tag,
  Loading,
  PullRefresh,
  Search,
  List,
  ActionSheet,
  Radio,
  RadioGroup
]

vantComponents.forEach(component => {
  app.use(component)
})

app.use(pinia)
app.use(router)

// 注册必需的组件
echarts.use([
  TitleComponent,
  TooltipComponent,
  GridComponent,
  LegendComponent,
  DataZoomComponent,
  MarkPointComponent,
  LineChart,
  CanvasRenderer
])

app.mount('#app')
